package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo7 {
    public static void main(String[] args) {
        try (Connection connection=DBUtil.getConnection())
        {
            Statement statement = connection.createStatement();
            String sql="select count(*) '人数' "+
                    "from student s,class c " +
                    "where s.class_id=c.id " +
                    "and c.name='1年级1班'";
            ResultSet resultSet = statement.executeQuery(sql);
            while(resultSet.next()){
                int count=resultSet.getInt("人数");
                System.out.println("1年级1班人数："+count);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
